<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title> 
<script type="text/javascript" src="__PUBLIC__/js/jquery-1.4.2.js"></script>
<style type="text/css">
<!-- 
.box{ margin:0px; padding:0px; float:left; width:480px; height:195px;}
.box .content{ margin:5px 0px 0px 18px; padding:0px; float:left; display:inline; width:455px; height:180px; }
.box .content h1{ margin:0px; padding:0px; float:left; height:30px; width:450px; line-height:30px; border-bottom:1px solid #adce88; font-size:12px; font-weight:bold;}
.input_btn{ margin:0px; padding:0px; width:455px; height:30px; float:left; text-align:center}
.inputtxt{ margin:0px; padding:0px; width:408px; height:99px; border:1px solid #cbcbcb}
.btn_input1{ margin:8px 5px 0px 0px; padding:0px; width:100px; height:22px; background:#8dc354; color:#ffffff; text-align:center; line-height:22px; border:0px; display:inline}
.btn_input2{ margin:8px 5px 0px 0px; padding:0px; width:55px; height:22px; background:#8dc354; color:#ffffff; text-align:center; line-height:22px; border:0px}

.content span{ margin:10px 0px 0px 0px; padding:0px; float:left; display:block}
.content label,.content div{ margin:10px 0px 0px 0px; padding:0px; float:left; width:430px}
.addname{ margin:10px 0px 0px 10px; padding:0px 0px 0px 0px; width:430px; display:inline; float:left;} 
-->
</style>
</head>

<body>
<form action="__URL__/upimgs"  method="POST" enctype="multipart/form-data">		
<div class="box">
	<div class="content">
	    <h1>添加图片</h1>
   		<div><span class="font_graylight">请选择图片文件，文件大小须小于2MB</span></div>
   		<div>or 创建目录 <input type="text" name="name" id="id_name" value="" />
   		<input type="button" value="创建" onclick="mkNameDir('id_name','fnames','snames')"/></div>
   		 <div>目录：<select name="fnames" id="fnames" onchange="chgSdir('fnames','snames')"><option value="">-请选择-</option>
   		 <?php echo $optf;?>
   		 </select>=><select name="snames" id="snames"><option value="">-请选择-</option>
   		 <?php echo $opts;?>
   		 </select>
   		 </div>
		 <div id="filelistipt">
		 <label><a href="javascript:;" onclick="addFileLabel('filelistipt','pics[]')">追加上传</a></label>
   		 <label><input name="pics[]" type="file" size="65" style="height:22px;" /></label>
         <label><input name="pics[]" type="file" size="65"  style="height:22px;" /></label>
         <label><input name="pics[]" type="file" size="65" style="height:22px;" /></label>
         </div>
		<div class="input_btn">
		 <input type="submit" name="submit" class="btn_input2" value="上传"/>
		</div> 
	</div>
</div>
 </form>
<script>
function mkNameDir(id,id1,id2){
	var dir = $("#"+id).val();
	var fdir = $("#"+id1).val(); 
	var url = "__URL__/ajax";
	var oper = 'mkdir'; 
	$.get(url,{oper:oper,dir:dir,fdir:fdir }, function(msg){ appendOpt(msg,id2); });  
}
function appendOpt(res,id2){ 
	if(res == '1'){
		alert('dir exists!');
		return false;
	}
	var opt = $("<option value='"+res+"' selected >"+res+"</option>"); 
	$("#"+id2).append(opt);
}	
function addFileLabel(id,names){
	var label = $('<label></label>');
	var ipt = $('<input type="file" name="'+names+'" size="65" style= "height:22px;"/>');  
	label.append(ipt);
	$("#"+id).append(label) ;
}
function chgSdir(id1,id2){
	var fdir = $("#"+id1).val();
	var url = "__URL__/ajax";
	var oper = 'chgdir'; 
	$.get(url,{oper:oper,fdir:fdir}, function(msg){chgOpt(id2, msg); });
}
function chgOpt(id,opts){
	var opt = '<option value="">-请选择-</option>';
	opt += opts;
	$("#"+id).html(opt);
}
</script>
</body>
</html>
